// pages/hongbao/index.js
const App = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isLogin: false,
    userInfo: {}, // 用户信息
    list:{},
    orderCount: {}, // 订单数量
    is_tel:false,
    is_huiyuan:true,
    type:0,
    money:'???',
    points:0,
    money_class_name:'xianshi',
    points_class_name:'yincang'
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  onShow() {
    let _this = this;
    _this.setData({
      isLogin: App.checkIsLogin()
    });
    // 获取当前用户信息
    _this.getUserDetail();
    _this.getHongBaoList()
  },
  /**
   * 获取当前用户信息
   */
  getUserDetail() {
    let _this = this;
    App._get('user.index/detail', {}, function(result) {
      _this.setData(result.data);
    });
  },
  /*
  */
 getHongBaoList(){
    let _this = this;
    App._get('Hongbao/index', {}, function(result) {
      _this.setData(result.data);
    });
 },
 addHongBao(){
   let _this = this
   App._post_form('Hongbao/hongBaoAdd', {}, function(result) {
    _this.setData(result.data);
     if(result.data.resule.status==200){
       if(result.data.resule.type == 0){
         var points_class = 'xianshi'
         var money_class = 'yincang'
       }else{
        var points_class = 'yincang'
        var money_class = 'xianshi'
       }
       _this.getUserDetail();
       _this.getHongBaoList()
        _this.setData({
          type:result.data.resule.type,
          points:result.data.resule.points,
          money:result.data.resule.money,
          money_class_name: money_class,
          points_class_name: points_class
        })
     }
  });
 },
 /**
   * 分享当前页面
   */
  onShareAppMessage() {
    let _this = this;
    return {
      title: '点击即可参与免费领红包，不差钱！！！',
      path: "/pages/hongbao/index"
    };
  },
 /**
   * 分享当前页面到朋友圈
   */
  onShareTimeline(){
    let _this = this;
    return {
      title: '点击即可参与免费领红包，不差钱！！！'
    };
  },
})